from pptx import Presentation
from pptx.util import Inches, Pt

ppt = Presentation()
# 在ppt中插入一个幻灯片(数字参数不同，插入样式也不同)
slide = ppt.slides.add_slide(ppt.slide_layouts[1])
# 占位符
body_shape = slide.shapes.placeholders
# body_shape[0].text = '占位符0'
# body_shape[1].text = '占位符1'
# title_shape = slide.shapes.title
# title_shape.text = '标题'
# subtitle = slide.shapes.placeholders[1]  # 取出本页第2个文本框
# subtitle.text = '文本框'
# new_paragraph = body_shape[1].text_frame.add_paragraph()
# new_paragraph.text = '新段落'
# new_paragraph.font.bold = True  # 加粗
# new_paragraph.font.italic = True  # 斜体
# new_paragraph.font.size = Pt(15)  # 字号
# new_paragraph.font.underline = True  # 下划线

left = Inches(5)
top = Inches(2)
width = Inches(3)
height = Inches(3)
textbox = slide.shapes.add_textbox(left, top, width, height)
textbox.text = '新文本框'
new_para = textbox.text_frame.add_paragraph()
new_para.text = '文本框第2段'

ppt.save('test_文字.pptx')